package com.timetask;

import java.util.Timer;
import java.util.TimerTask;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.bpms.common.CommonUtil;
import com.bpms.esb.SV;
/**
 * 任务定时器
 * @author menlin
 *
 */
public class MyTimerTask implements ServletContextListener {
	private static Timer timer = new Timer();
	private static final long ONE_MINUTE = 60 * 1000;
	private static final long ONE_HOUR = 60 * ONE_MINUTE;
	@Override
	public void contextDestroyed(ServletContextEvent sce) {
//		timer.cancel();
	}

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		// 定时发送交易单到集中作业管理中心
		timer.scheduleAtFixedRate(new Send_queryaccount(), 1000, 3 * ONE_MINUTE);
		
//		timer.scheduleAtFixedRate(new GetAccount(), 1000, ONE_HOUR);
	}

	/**
	 * 定时发送交易单据到集中作业管理中心
	 */
	private class Send_queryaccount extends TimerTask {

		@Override
		public void run() {
			CommonUtil.debug("Start MyTimerTask==>Send_queryaccount 进入连接集中作业管理中心定时任务--");
			
			SV.g("ATM.Send__queryaccount_request", null);
		}
	}
	
	private class GetAccount extends TimerTask{

		@Override
		public void run() {
			new UpdateAccountTimetask().execute();
		}
		
	}
}
